package biz.ezcom.spring.ioc.test;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import biz.ezcom.spring.ioc.pojo.Bean;

public class Client {
	private static ApplicationContext context;
	@BeforeClass
	public static void setUpBeforeClass() {
		context = new ClassPathXmlApplicationContext("applicationContext-bean.xml");
	}

	@Test
	public void testConstructor() {
		Bean bean = (Bean) context.getBean("constructor");
		System.out.println("constructor: bean.id = " + bean.getId());
	}
	@Test
	public void testSetter(){
		Bean bean = (Bean) context.getBean("setter");
		System.out.println("setter: bean.id = " + bean.getId());
	}
	@Test
	public void testInner(){
		Bean.Inner inner = (Bean.Inner) context.getBean("inner");
		System.out.println("静态内部类: Bean.Inner.name = "+ inner.getName());
	}
	@Test
	public void testStaticFactory(){
		Bean bean = (Bean) context.getBean("staticBean");
		System.out.println("静态工厂方法:bean.id = " + bean.getId());
	}
	@Test
	public void testInstanceFactory(){
		Bean bean = (Bean) context.getBean("instanceBean");
		System.out.println("实例工厂方法:bean.id = " + bean.getId());
	}
	
}
